package cn.dglydrpy.study.spring.ioc.postProcessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @Description: bean的后置处理器,默认对所有bean都有效 
 * @author:LY_飘涯
 * @date:2019年6月5日 下午5:46:39 
 * @version:1.0
 */
@Component 
public class MyBeanPostProcessor implements BeanPostProcessor{

	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		if("lifeCycleBean".equals(beanName) || "diyBean".equals(beanName) || "company".equals(beanName)) {
			System.out.println(beanName+" 执行BeanPostProcessor.postProcessBeforeInitialization");
		}
		return bean;
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		if("lifeCycleBean".equals(beanName) || "diyBean".equals(beanName) || "company".equals(beanName)) {
			System.out.println(beanName+" 执行BeanPostProcessor.postProcessAfterInitialization");
		}
		return bean;
	}

}
